#include <cstring>
#include <set>
#include <cstdlib>

//Generate unique random numbers from 0 to mod
class URandGen
{
	std::set<int> used;
	int limit;

public:
	URandGen(int lim) : limit(lim) { }
	int operator() ( )
	{
		while(true)
		{
			int i = int(std::rand()) % limit ;
			if(used.find(i) == used.end())
			{
				used.insert(i) ;
				return i ;
			}
		}
	}
};


	
